home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / share / eselect / libs / default.eselect < prev    next >
Text File  |  2006-04-12  |  3KB  |  110 lines

  1. #!/bin/bash
  2.  
  3. # Copyright (c) 2005 Gentoo Foundation.
  4. # $Id: default.eselect.in 209 2005-10-16 18:31:47Z ciaranm $
  5. # This file is part of the 'eselect' tools framework.
  6. #
  7. # eselect is free software; you can redistribute it and/or modify it under the
  8. # terms of the GNU General Public License as published by the Free Software
  9. # Foundation; either version 2 of the License, or (at your option) any later
  10. # version.
  11. #
  12. # eselect is distributed in the hope that it will be useful, but WITHOUT ANY
  13. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  14. # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License along with
  17. # eselect; if not, write to the Free Software Foundation, Inc., 59 Temple
  18. # Place, Suite 330, Boston, MA  02111-1307  USA
  19.  
  20. DESCRIPTION="No description available"
  21. VERSION="No version available"
  22. DEFAULT_ACTION="usage"
  23.  
  24. describe_usage() {
  25.     echo "Display usage information"
  26. }
  27.  
  28. do_usage() {
  29.     show_usage_message
  30.     if is_function show_extra_help_text ; then
  31.         echo
  32.         echo "Additional help is available via the 'help' action."
  33.     fi
  34.     true
  35. }
  36.  
  37. show_usage_message() {
  38.     echo "Usage: ${ESELECT_COMMAND} <action> <options>"
  39.     echo
  40.  
  41.     write_list_start "Standard actions:"
  42.     for action in "help" "usage" "version" ; do
  43.         local desc=""
  44.         is_function "describe_${action}" && desc=$(describe_${action} )
  45.         write_kv_list_entry "${action}" "${desc:-(no description)}"
  46.     done
  47.  
  48.     echo
  49.     write_list_start "Extra actions:"
  50.  
  51.     # FIXME: can we do this using expansion somehow?
  52.     for action in $(set | \
  53.             sed -n -e '/^do_\S\+ ()\s*$/s/^do_\(\S\+\).*/\1/p' | \
  54.             grep -v 'action' | \
  55.             sort ) ; do
  56.         case "${action}" in
  57.             help|usage|version)
  58.                 continue
  59.                 ;;
  60.             ?*)
  61.                 local desc="" line="" ifs_save="${IFS}" action_text=""
  62.                 is_function "describe_${action}" && desc=$(describe_${action} )
  63.  
  64.                 if is_function "describe_${action}_parameters" ; then
  65.                     action_text="${action} $(describe_${action}_parameters)"
  66.                 else
  67.                     action_text="${action}"
  68.                 fi
  69.  
  70.                 write_kv_list_entry "${action_text}" "${desc:-(no description)}"
  71.  
  72.                 if is_function "describe_${action}_options" ; then
  73.                     IFS=$'\n'
  74.                     for line in $(describe_${action}_options) ; do
  75.                         write_kv_list_entry -p \
  76.                             "  ${line%%*( ):*}" \
  77.                             "  ${line##+([^:]):*( )}"
  78.                     done
  79.                     IFS="${ifs_save}"
  80.                 fi
  81.                 ;;
  82.         esac
  83.     done
  84.     true
  85. }
  86.  
  87. describe_version() {
  88.     echo "Display version information"
  89. }
  90.  
  91. do_version() {
  92.     echo "Version ${VERSION}"
  93. }
  94.  
  95. describe_help() {
  96.     echo "Display help text"
  97. }
  98.  
  99. do_help() {
  100.     echo "${DESCRIPTION}"
  101.     show_usage_message
  102.     if is_function show_extra_help_text ; then
  103.         echo
  104.         show_extra_help_text
  105.     fi
  106.     true
  107. }
  108.  
  109. # vim: set sw=4 et sts=4 tw=80 :
  110.